<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>对象新增方法</title>
</head>
<body>

</body>
</html>
<script>
    // object.is
    console.log(Object.is(`foo`,`foo`));
    console.log(Object.is(+0,-0));
    console.log(Object.is(NaN,NaN))
//    Object.assign()对象的合并
   const target={a:1};
    const source1={b:2};
    const source2={c:3};
    const all=Object.assign(target,source1,source2);
    console.log(all);//同名属性会覆盖
//    如果不是对象会转换成对象,比如数组
    let a=Object.assign(222);
    console.log(a, typeof a)
    // ++++++++++++++++++++++++++++
//    浅拷贝和深拷贝
//     深拷贝   修改拷贝的新变量不会影响原有的值
    let m=1;
    let n=m;
    n=4;
    console.log(m,n);
//    浅拷贝
    const obj1={a:{b:2}};
    const obj2=Object.assign(obj1);
    obj2.a.b=7;
    console.log(obj1);
    console.log(obj2.a.b);
    // object.keys()返回一个数组,成员是参数对象自身的所有可遍历属性的键名
    let obj={a:'bbb',c:'222'};
    let a2=Object.keys(obj);
    console.log(a2);
//    object.entries()
    let cc=Object.entries(obj);
    console.log(cc);
//    Object.fromEntries()将一个键值对数组转换成对象
    let obj4=[["a",'haskjh'],["jjj","kkk"]]
    console.log(Object.fromEntries(obj4));

</script>
